<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script>
        window.hdjs = {};
        window.hdjs.base = '/hdjs';
        window.hdjs.uploader = 'php/uploader.php?';
        window.hdjs.filesLists = 'php/filesLists.php?';
    </script>
    <script src="../dist/static/requirejs/require.js"></script>
    <script src="../dist/static/requirejs/config.js"></script>
</head>
<body style="padding: 50px;">
<button onclick="upFile(this)" class="btn btn-default" type="button">选择文件</button>
<script>
    require(['hdjs']);
    //上传图片
    function upFile() {
        require(['hdjs'], function (hdjs) {
            var options = {
                extensions: 'txt,php',
                //data是向后台服务器提交的POST数据
                data:{name:'后盾人',year:2099},
                //单个文件允许为5MB
                fileSingleSizeLimit:5 * 1024 * 1024
            };
            hdjs.file(function (files) {
                //上传成功的文件，数组类型
                console.log(files);
            }, options)
        });
    }
</script>
</body>
</html>